package org.electric.util;

import java.util.List;

public class Page {
	
	private int pageNo;//当前页码
	
	private int pageSize = 4; //每页显示的记录   初始为每页显示3条记录
	
    private int indexNo;//第几条数据开始
    
  	private List list; //定义每页展示的内容集合
 
  	private int totalPage;  //总页数
  
  	private int totalNum;//总数据数
  	public Page(){}
  	
	public Page(int pageNo, int pageSize, int indexNo, List list, int totalPage, int totalNum) {
		super();
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.indexNo = indexNo;
		this.list = list;
		this.totalPage = totalPage;
		this.totalNum = totalNum;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		if(pageNo<=0){
			this.pageNo=1;	
			pageNo=this.pageNo;
		}
	  else if(pageNo>=getTotalPage()){
			this.pageNo=getTotalPage();	
			
		}
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getIndexNo() {
		return (pageNo-1)*pageSize;
	}

	public void setIndexNo(int indexNo) {
		
		this.indexNo = indexNo;
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public int getTotalPage() {

		totalPage = totalNum/pageSize;
		
		if(totalNum % pageSize != 0 ){
			totalPage++;
		}

		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getTotalNum() {
		return totalNum;
	}

	public void setTotalNum(int totalNum) {
		this.totalNum = totalNum;
	}
  	
  
  	
}
